package com.iknight.finance.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iknight.finance.dao.InvestInfoDao;
import com.iknight.finance.entity.InvestInfoEntity;
import com.iknight.finance.service.InvestInfoService;
import com.iknight.mgr.core.utils.IkgStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

@Service
public class InvestInfoServiceImpl<T extends Serializable> implements InvestInfoService<InvestInfoEntity> {
    @Autowired
    private InvestInfoDao<InvestInfoEntity> investInfoDao;

    @Override
    public void save(InvestInfoEntity entities) {

    }

    @Override
    public void delete(String ivsId) {

    }

    @Override
    public Object update(InvestInfoEntity entity) {
        return null;
    }

    @Override
    public PageInfo selectByPage(Map param) {
        boolean isPaging = (boolean) param.get("isPaging");
        if (isPaging) {
            int pageIndex = IkgStringUtils.ObjectToInt(param.get("pageNumber"));
            int pageSize = IkgStringUtils.ObjectToInt(param.get("pageSize"));
            PageHelper.startPage(pageIndex, pageSize, true);
        }
        List<InvestInfoEntity> resultLs = investInfoDao.selectByCond(param);
        PageInfo<InvestInfoEntity> result = new PageInfo<>(resultLs);

        return result;
    }
}
